function paramArray2obj(paramArray) {
    var obj = {};

    for ( var i = 0; i < paramArray.length; i++) {
        evalThem(paramArray[i].name, paramArray[i].value);
    }

    function evalThem(name, value) {
        var attributeName = name;
        var attributeValue = value;
        if (!attributeValue) {
            return;
        }

        var array = attributeName.split(".");
        for ( var i = 1; i < array.length; i++) {
            var tmpArray = Array();
            tmpArray.push("obj");
            for ( var j = 0; j < i; j++) {
                tmpArray.push(array[j]);
            }
            var evalString = tmpArray.join(".");
            if (!eval(evalString)) {
                eval(evalString + "={};");
            }
        }
        attributeValue=attributeValue.replace(/\r\n/g,"jj"); 
        eval("obj." + attributeName + "='" + attributeValue + "';");
    }

    return obj;
}

$.fn.form2json = function() {
    var paramArray = this.serializeArray();
    var obj = paramArray2obj(paramArray);
    return obj;
};
